#include <intrins.h>
#include <stdio.h>
#include <string.h>
#include "framework.h"
#include "user_config.h"
#include "service.h"



#define VERSION_MESSAGE "Programme starts! Designed by zhenhuanchn@qq.com, build on " __TIME__ "," __DATE__ "\r\n"


char putchar (char ch)
{
	uart1_write(&ch, sizeof(ch));
	return ch;
}



void core_timer_routine()
{
	soft_timer_pulse();
	KEY_SCAN_SHORT_LONG(KEY_TEST_INPUT,KEY_SHORT_TIME,EVENT_KEY_TEST_SHORT_PRESS,KEY_LONG_TIME,EVENT_KEY_TEST_LONG_PRESS);
}


void main(void)
{
	USER_CONFIG();
	timer0_init(TIMER_LOAD_VALUE16(0.001,FOSC,12), core_timer_routine);
	uart1_init(115200, 0, 0);
	AD_Power_On();

	INTERRUPT_ENABLE();
	timer0_start();
	service_init();
	printf(VERSION_MESSAGE);
	
	for(;;)
	{
		event_pull();
		soft_timer_pull();
	}
}


